Skip to main content

Active Vehicle Policy Export

Introduction​

The Active Vehicle Policy Export produces a daily CSV file listing vehicles with at least one active policy for a specified lease company. The file is packaged as a ZIP archive and delivered to Google Cloud Storage.

Generation is initiated by a Pub/Sub scheduler. There is no on-demand download option within the ViSN platform.

Purpose​

The AA requires a recurring export of vehicles that currently hold an active policy agreement. Each row provides the vehicle registration, make, model, date of first registration (DOFR), and a fixed scheme code for consumption by downstream AA systems.

File format​

Compressed ZIP file containing a CSV file

File Naming Convention

AA_Fleet_Export_<YYYY>-<MM>-<DD>_<HH>_<mm>_<ss>.zip

The CSV contained within the ZIP shares the same base name with a .csv extension (for example, AA_Fleet_Export_2026-07-01_00_00_00.csv).

Fields​

Column PositionHeader NameDescriptionDatatypeRulesMax lengthMandatoryDefault ValueExample
ARegistrationVehicle registration mark (VRM)stringTruncated to 8 characters when the value exceeds the maximum length8NoAB12CDE
BMakeVehicle makestring

Resolved in the following order:

  1. Stock record make.label
  2. VRM lookup vrmLookup.make.label

Truncated to 40 characters when the value exceeds the maximum length

40NoFord
CModelVehicle model from the stock recordstringTaken from stock.model as stored; VRM lookup is not usedNoFocus
DDOFRDate of first registrationstring

Resolved in the following order:

  1. Stock record registrationDate
  2. VRM lookup vrmLookup.registrationDate

Formatted as dd/MM/yyyy. Left empty when no valid date is available.

10No15/06/2020
EReserved blank columnstringAlways emptyNo
FScheme CodeAA scheme identifierstringHard-coded for every row3YesEH1EH1

Note: When data is unavailable for a field, the corresponding CSV value is left empty. Values containing commas are enclosed in quotes.

Storage locations​

Dated archive path

{bucketName}/{destinationFolder}/{year}/{month}/{day}/{AA_Fleet_Export_<timestamp>.zip}

The month folder uses the full English month name in lowercase (for example, july).

Pickup path

{bucketName}/{destinationFolder}/{AA_Fleet_Export_<timestamp>.zip}

The pickup path holds the latest export for downstream collection. Before each run, files located directly under {destinationFolder}/ are removed. Dated subfolders are retained.

Configuration​

No lease-company Firebase configuration document or feature flag governs this export. All runtime parameters are supplied in the Pub/Sub scheduler message body.

Cloud Function runtime options:

SettingLower environmentHigher environment
Timeout60 seconds300 seconds
Memory512 MiB1024 MiB

Dependencies​

  • Typesense — stock index with hasActivePolicy, leaseId, and contractStatus fields
  • Firestore — lease stock documents at /leasecompany/leaseId/stock
  • Google Cloud Storage — export file storage
  • Ancillary Firestore — process log persistence
  • Email queue — optional file delivery and notifications
  • Stock index maintenance — hasActivePolicy must remain synchronised via updateStockIndex when policies change

Setup Required​

A Cloud Scheduler task must be configured to publish messages at the required interval. Configure the task as follows:

  • Name: generateActivePolicyVehicleExportCSV
  • Region: europe-west2
  • Frequency: Daily (configure the cron expression to match operational requirements)
  • TimeZone: GMT London
  • Topic: projects/biddirect-2/topics/generateActivePolicyVehicleExportCSV
  • Message body: JSON object as described below

Pub/Sub message body

{
"leaseCompanyId": "<lease-company-id>",
"bucketName": "<gcs-bucket-name>",
"destinationFolder": "<folder-path-within-bucket>",
"emailExportsTo": "<recipient(s) for export file delivery>",
"successEmailSubject": "<subject for internal success notification>",
"successEmailToAddress": "<recipient for success and support contact in delivery email>",
"fatalErrorEmailToAddress": "<recipient for failure notification>",
"errorEmailSubject": "<subject for failure notification>"
}
ParameterRequiredDescription
leaseCompanyIdYesLease company whose active-policy vehicles are exported
bucketNameYesGCS bucket that receives the export file
destinationFolderYesFolder path within the bucket (no leading slash)
emailExportsToNoWhen provided, queues an EXPORT_FILE_DELIVERY email with the ZIP attached from storage
successEmailSubjectNoSubject for a plain-text success notification; requires successEmailToAddress
successEmailToAddressNoRecipient for the success notification; also supplied as supportEmailToAddress in the delivery email template
fatalErrorEmailToAddressNoRecipient for failure notification; requires errorEmailSubject
errorEmailSubjectNoSubject for failure notification

Example message body

{
"leaseCompanyId": "MyknPNP76jd4uebzantr",
"bucketName": "biddirect-2.appspot.com",
"destinationFolder": "aaActiveVehicles-exports",
"emailExportsTo": "recipient@example.com",
"successEmailSubject": "AA Active Vehicles Export Success",
"successEmailToAddress": "ops@example.com",
"fatalErrorEmailToAddress": "ops@example.com",
"errorEmailSubject": "AA Active Vehicles Export Failed"
}

Examples of Generated Files​

A sample CSV with data:

Registration,Make,Model,DOFR,,Scheme Code
AB12CDE,Ford,Focus,15/06/2020,,EH1
VW14KLS,VOLKSWAGEN,Golf,01/03/2026,,EH1

A CSV row where the model contains a comma (quoted):

AB12CDE,Ford,"Focus, ST-Line",15/06/2020,,EH1

An empty CSV file (no eligible vehicles):

Registration,Make,Model,DOFR,,Scheme Code

Troubleshooting​

SymptomLikely causeAction
Export fails immediatelyMissing required message parametersConfirm leaseCompanyId, bucketName, and destinationFolder are present in the scheduler message
Fewer vehicles than expectedTypesense filter or policy status mismatchVerify vehicle policies (LIVE_AGREEMENT, isPolicyAvailable, end date or openEnded); confirm contractStatus is not TERMINATED; validate the Typesense index
Empty exportNo vehicles meet eligibility criteriaExpected when no active-policy vehicles exist; confirm stock data for the lease company in ViSN
Pickup file missing but dated file existsCopy step failedReview Cloud Function logs for GCS copy errors
No email receivedEmail parameters omitted or email queue issueConfirm emailExportsTo and related addresses are configured; inspect email queue documents
Function timeoutLarge fleet exceeding runtime limitsReview vehiclesInExport in logs; the higher environment permits up to 300 seconds and 1024 MiB
Status: Accepted
Category: Protected
Authored By: Jeyakumar Arunagiri on Jul 1, 2026
Revisions: